package com.lujieni.dubboconsumer.controller;

import com.lujieni.dubboconsumer.service.HelloHandler;
import com.lujieni.dubbointerface.HelloService;
import com.lujieni.po.UserPO;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    // default loadbalance is random
    @DubboReference(loadbalance = "roundrobin", mock = "true", retries = 1, timeout = 2000)
    private HelloService helloService;

    @Autowired
    private HelloHandler helloHandler;

    @GetMapping("/hello")
    public String sayHello(String name){
        return helloService.sayHello(name);
    }

    @GetMapping("/getUserById")
    public UserPO getUserById(Integer id){
        return helloService.getUserById(id);
    }

    @GetMapping("/getNo")
    public String getNo(){
        return helloHandler.getNo();
    }



}
